<?php
//	  PHPcongrats - Holiday and Birthday Mailer
//	
//    Copyright (C) 2011  Matthias Nass
//
//    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.


session_start();
if ($_SESSION['loggedin'] == true){

	include "DBconnect.php";
	$query = "SELECT * FROM users;";
	$result = mysql_db_query($database, $query, $link);
	mysql_close($link);
	?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Benutzer Verwaltung</title>
<link rel="stylesheet" type="text/css" href="./styles.css">
<script type="text/javascript" src="./scripts.js"></script>
</head>
<body>
	<h2>PHPcongrats <img src='./icons/rosette.png' alt='Rosette'/></h2>
	<h1>Benutzerverwaltung <img src='./icons/user.png' alt='user'/></h1>
	<p class="message">
	<?php if($_SESSION['message'] == ''){}else{?>
	<img src='./icons/error.png' alt='attention'/> <?php echo $_SESSION['message']; }?>
	</p>
	<ul>
	<li><a href="./useradd.php"><img src='./icons/user_add.png' alt='add user'/> Benutzer hinzuf&uuml;gen</a></li>
	</ul>
	<table>
		<tr>
			<th><img src='./icons/user_edit.png' alt='edit user'/></th>
			<th><img src='./icons/user_delete.png' alt='delete user'/></th>
			<th>Vorname</th>
			<th>Nachname</th>
			<th>Benutzername</th>
			<th>E-Mail</th>
			<th>erstellt</th>
			<th>zuletzt ge&auml;ndert</th>
		</tr>
		<?php
		include 'datefunction.php';
		while ($row = mysql_fetch_row($result)) {

			echo "<tr>";
			echo "<td align='center'><a href='./usercha.php?id=".$row[0]."'><img src='./icons/user_edit.png' alt='edit user'/></a></td>";
			echo "<td align='center'><a href='./users.php' onclick='rMConfirm(\"actionremuser.php?id=".$row[0]."\")'><img src='./icons/user_delete.png' alt='delete user'/></a></td>";
			echo "<td width='100px'>".$row[1]."</td>";
			echo "<td width='100px'>".$row[2]."</td>";
			echo "<td width='100px'>".$row[3]."</td>";
			echo "<td width='100px'>".$row[4]."</td>";
			echo "<td width='100px'>".date_mysql2german($row[6])."</td>";
			echo "<td width='100px'>".date_mysql2german($row[7])."</td>";
			echo "</tr>";
		}?>

	</table>
	<p>
		<a href="./index.php"><img src='./icons/page_gear.png' alt='Gear Page'/> Verwaltung</a>
	</p>

</body>
</html>

		<?php
		$_SESSION['message'] = "";
} else{
    $_SESSION['last_location'] = "./users.php";
	header( 'Location: http:./login.php' );
}
?>